package cn.heiliu.selenium.service;

import cn.heiliu.selenium.domain.SeleniumProxy;
import cn.heiliu.selenium.domain.WebDriverStatus;
import cn.heiliu.selenium.exception.UnsupportedMethodException;
import org.openqa.selenium.WebDriver;

import java.nio.file.Path;

/**
 * @author wangyelou
 * @date 2021/6/14
 */
public interface IWebDriverService extends WebDriver {

    /**
     * 获取浏览器标志
     */
    public String getFlag();

    /**
     * 访问url
     * @param url
     * @param proxy
     * @param waitXpath
     * @param timeout
     * @return
     */
    public IWebDriverGetService fetch(String url, SeleniumProxy proxy, String waitXpath, long timeout);

    public IWebDriverGetService fetch(String url, SeleniumProxy proxy);

    public IWebDriverGetService fetch(String url, String waitXpath, long timeout);

    public IWebDriverGetService fetch(String url);

    /**
     * 获取当前状态
     * @return
     */
    public WebDriverStatus getStatus();

    /**
     * 加载插件
     * @param ext
     */
    public void installExt(Path ext);

    /**
     * 重置窗口
     * @return
     */
    public String resetWindow();

    /**
     * 禁止使用该方法
     * @return
     */
    @Override
    default String getPageSource() throws UnsupportedMethodException {
        throw new UnsupportedMethodException("method not supported, please used getContent");
    }


    /**
     * 禁止使用get方法
     * @param url
     */
    @Override
    default void get(String url) {
        throw new UnsupportedMethodException("method not supported, please used fetch");
    }

}
